function count_same_elements(collection) {
  let collectionA=[];
  for(let i=0;i<collection.length;)
    {

      let count=0;
      for (let j=i;j<collection.length;j++)
        {
          if (collection[i].substr(0,1)==collection[j].substr(0,1))
            count+=1;
        }
        collectionA.push({"name":collection[i].substr(0,1),"summary":count});
        i+=count;
    }
  for (let a=0;a<collection.length;a++)
    {
      if (collection[a].split('').length>1)
        {

          let b=parseInt(collection[a].replace(/[^0-9]/ig,''));
          for (let c=0;c<collectionA.length;c++)
            {
              if (collection[a].substr(0,1)==collectionA[c]["name"])
              {collectionA[c]={"name":collectionA[c]["name"],"summary":collectionA[c]["summary"]+ b -1};}
            }
        }
    }
  return collectionA;
}

module.exports = count_same_elements;
